package _11冒泡排序;

import java.util.Arrays;

public class Demo {
    public static void main(String[] args) {
        int[] arr ={5,3,1,2};
        //外循环控制比较的轮数
        for (int i = 0; i < arr.length - 1; i++) {
            //内循环控制每轮比较的次数
            for (int j = 0; j < arr.length-1-i; j++) {
                if (arr[j]>arr[j+1]){
                    int temp = arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }
            }
        }

        System.out.println(Arrays.toString(arr));
    }
}
